﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace JotCMS
{
    public class JotCMSConfiguration : ConfigurationSection
    {
        public static JotCMSConfiguration GetConfig()
        {
            return ConfigurationManager.GetSection("JotCMSGroup/JotCMSConfiguration") as JotCMSConfiguration;
        }

        [ConfigurationProperty("ConnectionStringName", DefaultValue="JotCMS", IsRequired = true)]
        public string ConnectionStringName
        {
            get
            {
                return this["ConnectionStringName"] as string;
            }
        }

        [ConfigurationProperty("Cache", DefaultValue=true, IsRequired = true)]
        public bool Cache
        {
            get
            {
                return (bool)this["Cache"];
            }
        }

        [ConfigurationProperty("CacheDuration", DefaultValue = 720, IsRequired = true)]
        public int CacheDuration
        {
            get
            {
                return (int)this["CacheDuration"];
            }
        }
    }

    public class Location : ConfigurationElement
    {
        [ConfigurationProperty("ConnectionStringName", IsRequired = true)]
        public string ConnectionStringName { get { return this["ConnectionStringName"] as string; } }

        [ConfigurationProperty("Cache", IsRequired = true)]
        public bool Cache { get { return (bool)this["Cache"]; } }

        [ConfigurationProperty("CacheDuration", DefaultValue=720, IsRequired = true)]
        public int CacheDuration { get { return (int)this["CacheDuration"]; } }
    }
}